<template>
	<view class="container">
		<view class="gradientBox paddingLayout">
			<IndexHeader />
		</view>
		<view>
			<IndexMain />
		</view>
	</view>
</template>

<script>
import IndexHeader from "./components/indexHeader/indexHeader.vue";
import IndexMain from "./components/indexMain/indexMain.vue";
import { mapActions } from "vuex";
import storage from "@/utils/storage";

export default {
	data() {
		return {};
	},
	methods: {
		...mapActions("userStore", ["getUserInfoAction","updateUserInfoAction"]),
		...mapActions("momentStore", [
			"getHomeMomentAction",
			"getLabelListAction",
		]),
		...mapActions("journalStore", ["getjournalListOptionAction"]),
		async initHome() {
			const userInfo = storage.getCache("userInfo");
			if (userInfo.id) {
                // 有登录信息 填充到vuex
                await this.updateUserInfoAction(userInfo.id)
			} else {
                // 如果本地没有存储 调用游客登录
				await this.getUserInfoAction();
			}
            await this.getLabelListAction();
            await this.getHomeMomentAction();
		},
	},
	created() {
		this.initHome();
	},
	watch: {},
	components: {
		IndexHeader,
		IndexMain,
	},
};
</script>

<style lang="scss" scoped></style>
<style>
page {
	background-color: #f3f5f6;
}
</style>
